﻿using BuzzX8.Xmpp.StreamElements;
using BuzzX8.Xmpp.StreamElements.Factories;
using NUnit.Framework;

namespace BuzzX8.Xmpp.Test.StreamElements.Factories
{
    public abstract class StreamElementFactoryTestBase<TFactory, TElement, TModel> where  TElement : StreamElement
                                                                                   where  TModel   : StreamElementModel
                                                                                   where  TFactory : StreamElementFactory<TElement, TModel>
    {
        [Test]
        public void Can_Correctly_Create_Element_With_Base_Attributes()
        {
            TFactory factory = CreateFactory();
            TModel elementModel = CreateBaseModel();

            TElement element = factory.Create(elementModel);

            VerifyCreatedElement(element, elementModel);
        }

        protected abstract TFactory CreateFactory();

        protected abstract TModel CreateBaseModel();

        protected abstract void VerifyCreatedElement(TElement element, TModel elementModel);

        protected TElement CreateElement(TModel model)
        {
            TFactory factory = CreateFactory();
            return factory.Create(model);
        }
    }
}
